﻿using Landpy.CruiseControlNet.FacadeInterface.ConfigurationModule;
using System.Windows.Forms;

namespace Landpy.CruiseControlNet.ConfigurationSidekick.ConfigTreeModule
{
    class TreeDirector
    {
        private TreeNodesBuilder TreeNodesBuilder { get; set; }

        public TreeDirector(CruiseControl cruiseControl)
        {
            if (cruiseControl != null)
            {
                this.TreeNodesBuilder = new TreeNodesBuilder(cruiseControl);
            }
        }

        public TreeNode Load()
        {
            TreeNode treeNode = null;
            if (this.TreeNodesBuilder != null)
            {
                var cruiseControlNode =  this.TreeNodesBuilder.BuildCruiseControlNode();
                this.TreeNodesBuilder.BuildInternalSecurityNode(cruiseControlNode);
                this.TreeNodesBuilder.BuildProjectsNode(cruiseControlNode);
                treeNode = this.TreeNodesBuilder.CruiseControlTreeNode;
            }
            return treeNode;
        }


    }
}
